
// === uuMix.date ===
// depend: uuMeta
/*
Date.prototype.toISOString() - return "2000-01-01T00:00:00Z"
Date.prototype.toGMTString(ms = void 0) - return "Wed, 26 Aug 2009 20:33:07 GMT"
 */
(function uuMixDateScope() {

// Date.prototype.toISOString - to ISO8601 date string
//    new Date().toISOString() -> "YYYY-MM-DDTHH:mm:ss[.sss]TZ"
function DateToISOString() { // @return String: "2000-01-01T00:00:00Z"
  // alias
  var dec2 = uuMeta.dec2,

  return this.getUTCFullYear()        + '-' +
         dec2[this.getUTCMonth() + 1] + '-' +
         dec2[this.getUTCDate()]      + 'T' +
         dec2[this.getUTCHours()]     + ':' +
         dec2[this.getUTCMinutes()]   + ':' +
         dec2[this.getUTCSeconds()]   + 'Z';
}

// Date.prototype.toGMTString - convert GMT format time string
function DateToGMTString(ms) { // @param Number(= undefined): Date.parse result
                               //          undefined is current time
                               // @return String: 
  var rv = ((ms === void 0) ? new Date()
                            : new Date(ms)).toUTCString();

  if (/UTC/.test(rv)) {
    rv = rv.replace(/UTC/, "GMT");
    (rv.length < 29) && (rv = rv.replace(/, /, ", 0")); // fix IE format
  }
  return rv;
}

// --- initialize ---

// --- export ---
uuMeta.mix(String.prototype, {
  toISOString: DateToISOString, // ECMAScript-262 5th
  toGMTString: DateToGMTString
}, 0, 0);

})(); // uuMix.date scope

